export default {
	//退出登录
	backLogin() {

		this.$confirm('您确定退出吗？', '提示', {
			confirmButtonText: '确定',
			cancelButtonText: '取消',
			type: 'warning'
		}).then(() => {
			this.onLoad(true, "正在退出，请稍后")
			this.axiosGets("Admin/loginOut", {}, function() {
				this.onLoad(false)
				// this.removeLocalStorage();
				localStorage.removeItem(this.sy);
				this.history('/')
			})

		}).catch(() => {
			this.$message({
				type: 'info',
				message: '已取消退出'
			})
		})
	},
	CalculationTime() {
		var now = new Date();
		var hour = now.getHours();
		if (hour < 6) {
			return "，  早上好。";
		} else if (hour < 9) {
			return "，  早上好。";
		} else if (hour < 12) {
			return "，  上午好。";
		} else if (hour < 14) {
			return "，  中午好。";
		} else if (hour < 18) {
			return "，  下午好。";
		} else if (hour < 19) {
			return "，  晚上好。";
		} else if (hour < 22) {
			return "，  晚上好。";
		} else {
			return "，  晚上好。";
		}
	},

	editPass() {
		this.form1.username = JSON.parse(localStorage.getItem(this.sy)).admin_name;
		this.dialogFormVisible = true;
	},

	submitAdd() {
		if (!this.form1.password || !this.form1.password2) {
			this.msgError("请输入密码!")
			return;
		}
		if (this.form1.password != this.form1.password2) {
			this.msgError("两次密码不一致!")
			return;
		}

		let para = {
			username: this.form1.username,
			name: this.form1.username,
			// remarks:this.form.remarks,
			password: this.form1.password,
			password2: this.form1.password2
		}
		para.id = this.form.id
		this.axiosPost('user/userEdit', para, res => {
			// console.log(res)
			if (res.data.code == 200) {
				this.msgSuccess(res.data.msg)
				this.dialogFormVisible = false
				this.form = {}
				this.getTableData()
			} else {
				this.msgError(res.data.msg)
			}
		})

	},
	resetForm() {
		// this.$refs[formName].resetFields();
		this.form1 = {
			username: '',
			password: '',
			password2: ''
		}
		this.dialogFormVisible = false;
	},
}
